#include <stdio.h>
#include <stdlib.h>
void mem_exit(void);
double *dvector(int n)
{
  double *out;
  if ((out = (double *) calloc((unsigned) n, sizeof(double))) == NULL)
    mem_exit();
  return (out);
}
double **dmatrix(int m, int n)
{
  double **out;
  int i;
  if ((out = (double **) calloc((unsigned) m, sizeof(double *))) == NULL)
    mem_exit();
  for (i = 0; i < m; i++)
    out[i] = dvector(n);
  return (out);
}
int *ivector(int n)
{
  int *out;
  if ((out = (int *) calloc((unsigned) n, sizeof(int))) == NULL)
    mem_exit();
  return (out);
}
int **imatrix(int m, int n)
{
  int **out;
  int i;
  if ((out = (int **) calloc((unsigned) m, sizeof(int *))) == NULL)
    mem_exit();
  for (i = 0; i < m; i++)
    out[i] = ivector(n);
  return (out);
}
void mem_exit(void)
{
  puts("Allocation fault in memory routines.\n");
  exit(1);
}
